<template>
    <div style="background: #fff; width: 100%">
        <a-tabs type="card" v-model:activeKey="activeKey" v-if="isRenderComponent">
            <a-tab-pane key="1" tab="北极星指标">
                <div style="padding: 16px">
                    <div>
                        <flexbox>
                            <img src="@/assets/images/beijixing/beijixing-icon.png" style="width: 24px" />
                            <span class="margin-l-8 font-w-b">指标公式拆分</span>
                        </flexbox>
                        <div style="color: #70798b" class="margin-t-8"
                            >拆分因子可靠性分析：黄色警告项越多代表数据录入规范性越差，指标可靠性越低；绿色项越多代表指标可靠性越高</div
                        >
                        <div style="margin-top: 24px; font-size: 16px">需求交付周期 = 需求上线时间 - 需求创建时间</div>

                        <flexbox
                            justify="space-between"
                            style="width: 70%"
                            :class="[detail.wrongTimeIndex && detail.wrongTimeIndex.length ? 'warning-cont' : 'success-cont', 'margin-t-16']"
                        >
                            <flexbox>
                                <ExclamationCircleFilled style="color: #faad14" v-if="detail.wrongTimeIndex && detail.wrongTimeIndex.length" />
                                <CheckCircleFilled style="color: #52c41a" v-else />
                                <span class="margin-l-8">需求跟踪矩阵异常</span>
                                <a
                                    class="margin-l-16"
                                    style="text-decoration: underline"
                                    @click="jumpTo('wrongTimeIndex')"
                                    v-if="detail.wrongTimeIndex && detail.wrongTimeIndex.length"
                                    >{{ detail.wrongTimeIndex.length }}条</a
                                >
                                <span class="margin-l-16" v-else>0</span>
                            </flexbox>
                            <span style="color: #70798b">影响指标：交付周期等阶段周期不准确</span>
                        </flexbox>
                        <flexbox
                            justify="space-between"
                            style="width: 70%"
                            :class="[
                                detail.lostBusinessConnect && detail.lostBusinessConnect.length ? 'warning-cont' : 'success-cont',
                                'margin-t-16'
                            ]"
                        >
                            <flexbox>
                                <ExclamationCircleFilled
                                    style="color: #faad14"
                                    v-if="detail.lostBusinessConnect && detail.lostBusinessConnect.length"
                                />
                                <CheckCircleFilled style="color: #52c41a" v-else />
                                <span class="margin-l-8">未录入业务需求数据</span>
                                <a
                                    class="margin-l-16"
                                    style="text-decoration: underline"
                                    @click="jumpTo('lostBusinessConnect')"
                                    v-if="detail.lostBusinessConnect && detail.lostBusinessConnect.length"
                                    >{{ detail.lostBusinessConnect.length }}条</a
                                >
                                <span class="margin-l-16" v-else>0</span>
                            </flexbox>
                            <span style="color: #70798b">影响指标：需求提出时间缺失、交付周期不准确</span>
                        </flexbox>

                        <flexbox justify="space-between" style="width: 70%" class="success-cont margin-t-16">
                            <flexbox>
                                <CheckCircleFilled style="color: #52c41a" />
                                <span class="margin-l-8">全生命周期管理</span>
                            </flexbox>
                            <span style="color: #70798b">影响指标： 需求全生命周期时间跟踪</span>
                        </flexbox>

                        <flexbox justify="space-between" style="width: 70%" class="success-cont margin-t-16">
                            <flexbox>
                                <CheckCircleFilled style="color: #52c41a" />
                                <span class="margin-l-8">启用上线前验证变更工单节点以及上线时间复核审批流程</span>
                            </flexbox>
                            <span style="color: #70798b">影响指标：上线时间较为可靠</span>
                        </flexbox>
                    </div>
                </div>
                <ZhiBiaoChaifen :detail="detail" style="margin-top: 32px" />
                <ZhiBiaoTongjiTable :detail="detail" v-if="detail.id && route.query.type === '1'" style="margin-top: 32px" />
            </a-tab-pane>
            <a-tab-pane key="2" tab="过程指标"> <div style="padding: 16px">暂无数据</div> </a-tab-pane>
        </a-tabs>
    </div>
</template>

<script lang="ts">
import { useRouter, useRoute } from 'vue-router';
import ZhiBiaoChaifen from './components/ZhiBiaoChaifen.vue';
import ZhiBiaoTongjiTable from '@/views/energyManage/beijixing/Detail/components/ZhiBiaoTongjiTable/index.vue';
import { ExclamationCircleFilled, CheckCircleFilled } from '@ant-design/icons-vue';
import { useIsRenderComponent } from '@/hooks/useIsRenderComponent';
import { defineComponent, reactive, toRefs } from 'vue';
interface State {
    activeKey: string;
}
export default defineComponent({
    name: 'ZiyanDetail',
    components: {
        ExclamationCircleFilled,
        CheckCircleFilled,
        ZhiBiaoChaifen,
        ZhiBiaoTongjiTable
    },
    props: {
        detail: {
            type: Object,
            default: () => ({})
        }
    },
    setup() {
        const router = useRouter();
        const route = useRoute();
        const { isRenderComponent } = useIsRenderComponent();
        const state = reactive<State>({
            activeKey: '1'
        });
        const jumpTo = (key) => {
            router.push({
                path: '/energyManage/beijixing/detail/requireTrack',
                query: {
                    ...route.query,
                    key
                }
            });
        };
        return {
            ...toRefs(state),
            route,
            isRenderComponent,
            jumpTo
        };
    }
});
</script>

<style scoped lang="less">
// // 去掉表头颜色
::v-deep(.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab) {
    margin-right: 0px !important;
    border: none;
    background: #edeff3;
    border-radius: 0;
}
::v-deep(.ant-tabs.ant-tabs-card .ant-tabs-card-bar .ant-tabs-tab-active) {
    background: #fff;
    border-radius: 4px 4px 0px 0px;
}

.warning-cont {
    color: #505a6e;
    background: #fff7e6;
    border: 1px solid #ffe58f;
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 4px;
}
.success-cont {
    color: #505a6e;
    background: #f6ffed;
    border: 1px solid #b7eb8f;
    padding: 6px 12px;
    font-size: 14px;
    border-radius: 4px;
}
</style>
